package com.cskt.common.exception;

import com.cskt.common.constants.ErrorCodeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel("自定义系统异常")
public class SysException extends RuntimeException{
    @ApiModelProperty("异常状态码")
    private String errorCode;

    //构造异常：传入异常信息和code
    public SysException(String massage,String errorCode){
        //把异常信息保存到运行时异常类中
        super(massage);
        //把状态码保存在当前类中
        this.errorCode=errorCode;
    }

    //构造异常：传入异常枚举
    public SysException(ErrorCodeEnum errorCodeEnum){
        super(errorCodeEnum.getMsg());
        this.errorCode=errorCodeEnum.getErrorCode();
    }
}
